package com.yixing.tech.common.base;


import java.io.Serializable;

/**
 * @author yixing tech
 */
public class PageRow<T> implements Serializable {
    /**
     * 页数
     */
    public int pageNo;

    /**
     * 每页大小
     */
    private int pageSize;


    private T condition;

    public int getPageNo() {
        if (this.pageNo <= 0) {
            this.pageNo = 1;
        }
        return pageNo - 1;
    }

    public int getPageSize() {
        if (pageSize < 0) return Integer.MAX_VALUE;
        return pageSize;
    }

    public T getCondition(Class<T> c) {
        try {
            condition = condition == null ? c.newInstance() : condition;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return condition;
    }

    public T getCondition() {
        return condition;
    }

    public void setCondition(T condition) {
        this.condition = condition;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

}
